home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 19.zip
/
BS1 part 19
/
how to learn assembler.adf
/
CH4
/
4_3_2B-hex-bin2.asm
< prev
next >
Wrap
Assembly Source File
|
1988-02-25
|
827b
|
30 lines
;(4.3.2B) bin-hex2
hexlong:
lea buffer,a0 ; Pointer to the buffer
move.l #$12345678,d1 ; Data we want to convert
move #7,d3 ; Counter for the nibbles: 8-1
loop:
rol #4,d1 ; Move upper nibble into lower
move d1,d2 ; Write in d2
bsr nibble ; And convert it
move.b d2,(a0)+ ; Character in buffer
dbra d3,loop ; Repeat 8 times
rts
nibble:
and #$0F,d2 ; Just keep low byte
add #$30,d2 ; Add $30
cmp #$3A,d2 ; Was it a digit?
bcs ok ; Yes, done
add #7,d2 ; Else add 7
ok:
rts ; Bye-bye
buffer:
DS.B 9 ; Enough space for 8 hex digits and a null byte
end